package com.iris.thread.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * 项目: thinking
 * 包名: com.iris.thread.callable
 * 作者: victor
 * 日期: 2016年10月31日
 * 说明: CallableTest
 */
public class CallableTest {
	public static void main(String[] args) {
		ExecutorService es = Executors.newFixedThreadPool(2);
		Future<String> future = es.submit(new CallableRunnable());
		System.out.println("begin");
		try {
			System.out.println(future.get());
		} catch (InterruptedException e) {
			e.printStackTrace();
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
		System.out.println("end");
	}
}

class CallableRunnable implements Callable<String>{

	@Override
	public String call() throws Exception {
		Thread.sleep(2000);
		return "33";
	}
	
}
